package com.cw.jeeyt.service.converter.system;

import java.util.ArrayList;
import java.util.List;

import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.cw.jeeyt.service.bo.system.SystemDataEntryBo;
import com.cw.jeeyt.dao.model.system.SystemDataEntryDo;
import com.cw.lang.common.utils.CollectionUtil;

/**
 * 数据条目信息转换类
 *
 * @author chenw
 * @date 2019-03-10 13:04:25
 */
public class SystemDataEntryConverter {

    /**
     * do转bo
     *
     * @param model
     * @return
     */
    public static SystemDataEntryBo do2Bo(SystemDataEntryDo model) {
        if (model == null) {
            return null;
        }
        SystemDataEntryBo bo = new SystemDataEntryBo();
        bo.setId(model.getId());
        bo.setDataCode(model.getDataCode());
        bo.setDataName(model.getDataName());
        bo.setDataType(model.getDataType());
        bo.setDataLength(model.getDataLength());
        bo.setDataPoint(model.getDataPoint());
        bo.setDataJavaCode(model.getDataJavaCode());
        bo.setDataJavaType(model.getDataJavaType());
        // bo.setDataGroup(model.getDataGroup());
        bo.setProjectId(model.getProjectId());
        bo.setDataComment(model.getDataComment());
        bo.setCreateBy(model.getCreateBy());
        bo.setCreateDate(model.getCreateDate());
        bo.setUpdateBy(model.getUpdateBy());
        bo.setUpdateDate(model.getUpdateDate());
        return bo;
    }

    /**
     * bo转do
     *
     * @param bo
     * @return
     */
    public static SystemDataEntryDo bo2Do(SystemDataEntryBo bo) {
        if (bo == null) {
            return null;
        }
        SystemDataEntryDo model = new SystemDataEntryDo();
        model.setId(bo.getId());
        model.setDataCode(bo.getDataCode());
        model.setDataName(bo.getDataName());
        model.setDataType(bo.getDataType());
        model.setDataLength(bo.getDataLength());
        model.setDataPoint(bo.getDataPoint());
        model.setDataJavaCode(bo.getDataJavaCode());
        model.setDataJavaType(bo.getDataJavaType());
        // model.setDataGroup(bo.getDataGroup());
        model.setProjectId(bo.getProjectId());
        model.setDataComment(bo.getDataComment());
        model.setCreateBy(bo.getCreateBy());
        model.setCreateDate(bo.getCreateDate());
        model.setUpdateBy(bo.getUpdateBy());
        model.setUpdateDate(bo.getUpdateDate());
        return model;
    }

    /**
     * doList转boList
     *
     * @param doList
     * @return
     */
    public static List<SystemDataEntryBo> doList2BoList(List<SystemDataEntryDo> doList) {
        if (CollectionUtil.isEmpty(doList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(), SystemDataEntryConverter::do2Bo));
    }

    /**
     * boList转doList
     *
     * @param boList
     * @return
     */
    public static List<SystemDataEntryDo> boList2DoList(List<SystemDataEntryBo> boList) {
        if (CollectionUtil.isEmpty(boList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(), SystemDataEntryConverter::bo2Do));
    }
}